﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title></title>
    <link href="../Layui/css/layui.css" rel="stylesheet" />
    <style>
        .teacherCourse {
            border-radius: 5px;
            padding: 5px;
            margin: 5px;
        }

        .teacherCourseTd {
            padding: 0px !important;
            width: 10rem;
        }

        body {
            background-color: #fff;
        }

        .btnEdit {
            width: 0.8rem;
            float: right;
            margin-right: 5px;
            cursor: pointer;
        }

        .btnAdd {
            width: 0.8rem;
            float: right;
            margin-right: 15px;
            cursor: pointer;
        }

        .layui-table th {
            text-align: center;
        }
    </style>
</head>
<body>
    <form class="layui-form" action="">
        <div class="layui-tab layui-tab-brief" lay-filter="tab">
            <ul class="layui-tab-title">
                <li class="layui-this">按课程</li>
                <li>按学生</li>
            </ul>

            <div class="layui-tab-content" style="height: 100px;">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="date" lay-verify="date" placeholder="请选择日期" autocomplete="off" class="layui-input" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                            </div>
                        </div>
                        <div id="divD">
                            <table class="layui-table">
                                <thead>
                                    <tr>
                                        <th>课程表</th>
                                        <th v-for="item in Data.header">{{item.name}}</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr v-for="item1 in Data.time">
                                        <td style="width:3rem">{{item1.starttime}}-{{item1.endtime}}</td>
                                        <template v-for="item2 in Data.header">
                                            <td class="teacherCourseTd" valign="top">
                                                <template v-for="item3 in Data.teacherCourse" v-if="item1.id==item3.timeid&&item2.id==item3.classroomid">
                                                    <div v-bind:style="{background: item3.color}" class="teacherCourse">
                                                        <img src="../images/icon_pepole.png" class="btnEdit" @Html.Raw("@click")="openEdit(item3.id,item3.keycode,item3.coursename)" v-if="isEdit" />
                                                        <span style="color:white">{{item3.coursename}}-{{item3.teachername}} {{item3.twoteachername}}</span>
                                                        <br />
                                                        <span style="color:white">报名人数：{{item3.count}}/{{item3.studentnumber}}</span>
                                                        <template v-if="item3.signcount>0">
                                                            <br />
                                                            <span style="color:white">
                                                                签到学员：
                                                                <template v-for="item4 in Data.sign">
                                                                    <template v-if="item4.state==1&&item4.tid==item3.id&&item4.signupclass==0">
                                                                        {{item4.custname}}{{item4.isauditions}}
                                                                    </template>
                                                                </template>
                                                            </span>
                                                        </template>
                                                        <template v-if="item3.nosigncount>0">
                                                            <br />
                                                            <span style="color:white">
                                                                未到学员：
                                                                <template v-for="item4 in Data.sign">
                                                                    <template v-if="item4.state==0&&item4.tid==item3.id&&item4.signupclass==0">
                                                                        {{item4.custname}}{{item4.isauditions}}
                                                                    </template>
                                                                </template>
                                                            </span>
                                                        </template>
                                                        <template v-if="item3.truancycount>0">
                                                            <br />
                                                            <span style="color:white">
                                                                旷课学员：
                                                                <template v-for="item4 in Data.sign">
                                                                    <template v-if="item4.state==3&&item4.tid==item3.id&&item4.signupclass==0">
                                                                        {{item4.custname}}{{item4.isauditions}}
                                                                    </template>
                                                                </template>
                                                            </span>
                                                        </template>
                                                        <template v-if="item3.leavecount>0">
                                                            <br />
                                                            <span style="color:white">
                                                                请假学员：
                                                                <template v-for="item4 in Data.sign">
                                                                    <template v-if="item4.state==4&&item4.tid==item3.id&&item4.signupclass==0">
                                                                        {{item4.custname}}{{item4.isauditions}}
                                                                    </template>
                                                                </template>
                                                            </span>
                                                        </template>
                                                        <template v-if="item3.waitcount>0">
                                                            <br />
                                                            <span style="color:white">
                                                                排队学员：
                                                                <template v-for="item4 in Data.sign">
                                                                    <template v-if="item4.tid==item3.id&&item4.signupclass==1">
                                                                        {{item4.custname}}{{item4.isauditions}}
                                                                    </template>
                                                                </template>
                                                            </span>
                                                        </template>
                                                    </div>
                                                </template>
                                            </td>
                                        </template>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <iframe id="ifr" style="width:100%;height:500px;" frameborder="0"></iframe>
                </div>

            </div>
        </div>
    </form>
    <script type="text/javascript" src="../Htc/vue.js"></script>
    <script type="text/javascript" src="../Htc/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="../Layui/layui.js"></script>
    <script>

            var tabIndex = 0;
            layui.use(['form', 'laydate', 'element'], function () {
                var laydate = layui.laydate;
                var form = layui.form;
                var element = layui.element;
                //执行一个laydate实例
                laydate.render({
                    elem: '#date' //指定元素
                    ,done: function (value, date, endDate) {
                        getDayData();
                    }
                });

                //tab切换
                element.on('tab(tab)', function (data) {
                    tabIndex = data.index;
                    if (tabIndex == 0)
                        getDayData();
                    else if (tabIndex == 1) {
                        var url = "../Main/ManagerLay?type=CourseStudent3";
                        $("#ifr").css("height", $(window).height()-70)
                        $("#ifr").attr("src", url);
                    }
                });


            });

            var vmD = new Vue({
                el: '#divD',
                data: {
                    Data: {},
                    isEdit:false
                },
                methods: {
                    openEdit: function (id, keyCode, courseName) {
                        openStudent(id, keyCode, courseName)
                    }
                }
            });

            //获取按天数据
            function getDayData() {
                vmD.isEdit = $("#date").val() >='@DateTime.Now.ToString("yyyy-MM-dd")',//选择日期<当前日期不能修改增加;
                $.ajax({
                    type: 'POST',
                    url: '../Schedule/StudentClass/DayData',
                    data: {
                        date: $("#date").val(),
                        range: 0
                    },
                    dataType: "json",
                    success: function (data) {
                        if (data.code == "0000") {
                            vmD.Data = data.data;
                        }
                        else
                            layui.layer.msg(data.message);
                    }
                });
            }

            //打开编辑
        function openStudent(id, keyCode, courseName) {
                var title = '选择学员';
                var index = layui.layer.open({
                    type: 2,
                    content: '../ManagerLay?type=CourseStudent2&id=' + id + '&keyCode=' + keyCode + '&courseName=' + courseName,
                    title: title,
                    maxmin: true
                });
                layui.layer.full(index);
            }
            //初始加载获取天数
            getDayData();

            function HideModal(id) {
                layui.layer.closeAll();
            }
            //刷新数据
            function Reload() {
                if (tabIndex == 0)
                    getDayData();
            }
    </script>
</body>
</html>
